'''
Created on 10 Dec 2009

@author: jd437
'''

fieldsize=120000
dots=60000
s=fieldsize/dots #scaling factor

def CCCelement(shape):
    if shape.struc=='bar':
        coords='DWSL('
        for j in range(0,4,2):
            coords+=str(shape.coords[j][0]/s)+','+str(shape.coords[j][1]/s)+','
        coords+='1,0);3'            
    elif shape.struc=='bt':
        coords='DWTZL('
        for j in range(0,4,1):
            coords+=str(shape.coords[j][0]/s)+','+str(shape.coords[j][1]/s)+','
        coords+='1,0);3'
    return coords
        
def CCCwriter(shape_list,name):
    f=open(name+'.CCC', 'w')
    f.write('/*--- 1.CCC ---*/\n/* CZ0.12,60000 */\nPATTERN\n')
    f.close()
    f=open(name+'.CCC', 'a')
    for i in range(0, len(shape_list)):
        f.write(CCCelement(shape_list[i])+'\n')
    f.write('!END')
    f.close()
    
    f=open(name+'.CON','w')
    f.write('/*--- '+name+'.CON ---*/\nCZ0.12,60000;\nPC'+name+';\n0.00000,0.00000;\nPP'+name+';\n0.00000,0.00000;\n!END')